Skip to content

TypeSchema/API: Add collision resolution config#106

Merged
ryukzak merged 3 commits intomainfrom
resolve-collisions
Mar 18, 2026
Merged

TypeSchema/API: Add collision resolution config#106
ryukzak merged 3 commits intomainfrom
resolve-collisions

Conversation

@ryukzak
Copy link
Copy Markdown
Collaborator

@ryukzak ryukzak commented Mar 16, 2026

Collision resolution

  • Add resolveCollisions option to .typeSchema() for explicit control over duplicate schema selection
    • Key: binding URL (e.g. urn:fhir:binding:ObservationCategory), value: { package, canonical } identifying the preferred source
    • Unresolved collisions keep current behavior (pick most common, warn #duplicateSchema)
    • Mismatched config emits #resolveCollisionMiss warning
  • IR report enhancements:
    • Version marks: (selected) for user-configured, (auto) for heuristic-picked
    • Suggested resolveCollisions config snippet for unresolved collisions

Config example:

.typeSchema({
    resolveCollisions: {
        "urn:fhir:binding:ObservationCategory": {
            package: "hl7.fhir.r4.core#4.0.1",
            canonical: "http://hl7.org/fhir/StructureDefinition/Observation",
        },
    },
})

Generated report example:

## Schema Collisions

- `urn:fhir:binding:CommunicationReason` (2 versions)
  - Version 1 (selected): Communication (hl7.fhir.r4.core#4.0.1)
  - Version 2: CommunicationRequest (hl7.fhir.r4.core#4.0.1)
- `urn:fhir:binding:ProcessPriority` (2 versions)
  - Version 1 (auto): Claim (hl7.fhir.r4.core#4.0.1), CoverageEligibilityRequest (hl7.fhir.r4.core#4.0.1)
  - Version 2: ExplanationOfBenefit (hl7.fhir.r4.core#4.0.1)

### Suggested `resolveCollisions` config

.typeSchema({
    resolveCollisions: {
        "urn:fhir:binding:ProcessPriority": {
            package: "hl7.fhir.r4.core#4.0.1",
            canonical: "http://hl7.org/fhir/StructureDefinition/Claim",
        },
    },
})

Refactoring

  • Group treeShake, promoteLogical, resolveCollisions under options.typeSchema?: IrConf in APIBuilderOptions

Documentation

  • Add "Resolving Schema Collisions" section to README with warning explanation, fix instructions, and report output example
  • Update CLAUDE.md and README APIBuilder flow examples

@ryukzak ryukzak force-pushed the resolve-collisions branch from d438317 to 1b28f5b Compare March 16, 2026 14:25
@ryukzak ryukzak changed the title TypeSchema/API: Add collision resolution and choice narrowing TypeSchema/API: Add collision resolution config Mar 16, 2026
@ryukzak ryukzak force-pushed the resolve-collisions branch from 1b28f5b to 923c394 Compare March 16, 2026 14:28
@ryukzak ryukzak force-pushed the resolve-collisions branch from 511db83 to e09c7ab Compare March 16, 2026 14:35
@ryukzak ryukzak merged commit f9ba379 into main Mar 18, 2026
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant